<template>
	<view>
		<u-navbar title-color="#fff" :borderBottom="false" titleColor="#000000" :title="title" backIconSize="40"
			back-icon-color="#000000" :background="background"></u-navbar>
		<view class="top">
			<view class="left">
				<view class="name">
					{{title}}
				</view>
				<view class="text">
					蜂巢稍纵即逝，请快速选择心仪蜂巢
				</view>
			</view>
		</view>
		<view class="content">
			<view v-if="list.length>0">
				<view class="list" v-if="item.show" v-for="(item,index) in list" :key="index">
					<view class="number">
						<view class="down">
							信用等级
						</view>
						<view class="up font">
							{{item.price}} <text>Fmb</text>
						</view>
						<view class="text">
							当前价值
						</view>
					</view>
					<view class="icon" @click="doBuy(item,index)">
						<image src="../static/c2.png" mode=""></image>
					</view>
				</view>
			</view>
			<view v-else class="nonetow">
				<image src="../static/img.png" mode=""></image>
			</view>
		</view>
		<u-popup v-model="logistics" close-icon-pos="top-left" mode="bottom" :closeable="true" borderRadius="10">
			<view class="fight">
				<view class="title_item">
					恭喜抢购蜂巢成功
				</view>
				<view class="icon">
					<image src="/static/image/p0.png" mode=""></image>
				</view>
				<view class="appeal">
					请到我的-蜂巢凭证中 进行下一步操作
				</view>
				<button type="default" class="button" @click="zhidao">前往查看</button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				background: {
					'background': 'transparent'
				},
				logistics: false,
				title: "",
				maid: "",
				count: "",
				list: [],
				page: 1,
				orderno: "",
				sort_value: 1,
				timeout: 5000,
				timeout2: 500,
				index: 0,
				data: {},
				logo: ""
			}
		},
		onLoad(option) {
			than = this;
			than.title = "特权抢拍区"
			than.listOfOnsale()
		},
		onReachBottom() {
			than.page++;
			than.listOfOnsale()
		},
		methods: {
			sort() {
				than.sort_value = than.sort_value == 1 ? 2 : 1;
				than.page = 1;
				uni.showLoading({
					title: '请稍后'
				});
				this.$u.throttle(this.listOfOnsale, this.timeout);
				setTimeout(function() {
					uni.hideLoading();
				}, 5000);
			},
			getResult() {
				than.post("api/Novice_goods/doBuy", {
					page: than.page,
					pid: than.data.pid
				}, function(data) {
					than.orderno = data;
					than.list[than.index].show = false;
					than.logistics = true;
				})
			},
			doBuy(data, index) {
				than.data = data;
				than.index = index;
				this.$u.debounce(this.getResult, this.timeout2, false);
			},
			zhidao() {
				than.logistics = false;
				than.toPage('/pages/htmlB/voucher/index?orderno=' + than.orderno)
			},
			refresh() {
				than.page = 1;
				uni.showLoading({
					title: '请稍后'
				});
				than.$u.throttle(this.listOfOnsale, this.timeout);
				setTimeout(function() {
					uni.hideLoading();
				}, 5000);
			},
			listOfOnsale() {
				than.post("api/Novice_goods/listOfOnsale", {
					page: than.page,
				}, function(data) {
					than.count = data.count;
					for (let i in data.list) {
						data.list[i].show = true
					}
					if (than.page == 1) {
						than.list = data.list;
					} else {
						than.list = than.list.concat(data.list)
					}
					/* setTimeout(function() {
						uni.hideLoading();
					}, 1000); */
				})
			}
		}
	}
</script>

<style lang="less">
	.nonetow {
		text-align: center;

		image {
			width: 678rpx;
			height: 281rpx;
		}

		.text {
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #333333;
			margin-top: 61rpx;

			text {
				font-size: 36rpx;
				color: #FFC31E;
			}
		}
	}

	page {
		background: #FAFAFA;
	}

	.fight {
		text-align: center;
		padding-bottom: 32rpx;

		.title_item {
			height: 113rpx;
			line-height: 113rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
			border-bottom: 1px solid #F6F6F6;
		}

		.appeal {
			margin-top: -20rpx;
			margin-bottom: 40rpx;
			padding: 0 250rpx;
			font-size: 24rpx;
			line-height: 36rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #666666;
		}

		.icon {
			text-align: center;
			image {
				width: 426rpx;
				height: 391rpx;
			}
		}

		.button {
			width: 245rpx;
			height: 74rpx;
			background: #FB683D;
			border-radius: 20rpx;
			font-size: 28rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.content {
		position: relative;
		z-index: 22;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		/* #ifdef APP-PLUS */
		margin-top: calc(200rpx - var(--status-bar-height));
		/* #endif */
		/* #ifdef H5 */
		margin-top: 200rpx;
		/* #endif */
		width: 100%;

		.list {
			margin: 0 auto 24rpx;
			background: #FFFFFF;
			width: 678rpx;
			border-radius: 20rpx;
			height: 191rpx;
			position: relative;
			display: flex;
			align-items: center;

			.img {
				position: absolute;
				top: 1rpx;
				right: 19rpx;
				width: 50rpx;
				height: 50rpx;
			}

			.icon {
				margin-right: 60rpx;
				margin-left: auto;

				image {
					width: 77rpx;
					height: 77rpx;
				}

				.name {
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #666666;
				}
			}

			.number {
				width: 250rpx;
				margin-left: 24rpx;

				.up {
					font-style: initial;
					font-size: 56rpx;
					font-family: Myriad Pro;
					font-weight: 400;
					color: #1B1B1B;

					text {
						margin-left: 10rpx;
						font-size: 32rpx;
					}
				}

				.down {
					display: initial;
					background: #F5E5D8;
					padding: 5rpx 9rpx;
					border-radius: 12rpx;
					font-size: 22rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #B8845C;
				}
			}
		}
	}

	.title {
		padding: 0 62rpx;
		height: 100rpx;
		line-height: 100rpx;
		background: #FFFFFF;
		border-radius: 40rpx 40rpx 0rpx 0rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;

		.img {
			width: 390rpx;
			height: 50rpx;
			position: absolute;
			left: 218rpx;
			top: 25rpx;
		}
	}

	.top {
		/* #ifdef APP-PLUS */
		height: calc(340rpx + var(--status-bar-height));
		/* #endif */
		/* #ifdef H5 */
		height: 340rpx;
		/* #endif */
		position: fixed;
		top: 0;
		width: 100%;
		display: flex;
		align-items: center;
		z-index: 20;

		.left {
			padding-left: 61rpx;

			.name {
				font-size: 46rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
			}

			.text {
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #333333;

				text {
					font-weight: bold;
					color: #3362FA;
					font-size: 36rpx;
					margin: 0 10rpx;
				}
			}
		}

		.right {
			padding-right: 35rpx;
			margin-left: auto;
			display: flex;
			align-items: center;

			.list {
				text-align: center;

				image {
					width: 78rpx;
					height: 78rpx;
				}

				.name {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}

				margin-left:40rpx;
			}
		}
	}
</style>
